import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


const home = r => require.ensure([], () => r(require('../pages/home/home')), 'home')
const city = r => require.ensure([], () => r(require('../pages/city/city')), 'city')
const msite = r => require.ensure([], () => r(require('../pages/msite/msite')), 'msite')
const food = r => require.ensure([], () => r(require('../pages/food/food')), 'food')
const login = r => require.ensure([], () => r(require('../pages/login/login')), 'login')
const profile = r => require.ensure([], () => r(require('../pages/profile/profile')), 'profile')
const info = r => require.ensure([], () => r(require('../pages/profile/children/info')), 'info')
const search = r => require.ensure([], () => r(require('../pages/search/search')), 'search')
const order = r => require.ensure([], () => r(require('../pages/order/order')), 'order')
const shop = r => require.ensure([], () => r(require('../pages/shop/shop')), 'shop')

export default new VueRouter({
    mode: 'hash',
    routes: [
        {
            path: '',
            redirect: '/home'
        },
        {
            path: '/home',
            component: home
        },
        {
            path: '/city/:cityid',
            component: city
        },
        {
            path: '/msite',
            component: msite,
            meta: { keepAlive: true },
        },
        {
            path: '/food',
            component: food
        },
        {
            path: '/login',
            component: login
        },
        {
            path: '/profile',
            component: profile,
            children: [
                { path: 'info', component: info }
            ]
        },
        {
            path: '/search',
            component: search
        },
        {
            path: '/order',
            component: order
        },

        {
            path: '/shop',
            component: shop
        },
    ]
})